package com.shuaitao.myblog.controller;

import com.shuaitao.myblog.bean.Blog;
import com.shuaitao.myblog.service.BlogService;
import com.shuaitao.myblog.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/blog")
@CrossOrigin
public class BlogController {

    @Autowired
    private BlogService blogService;




    @RequestMapping("/getBlogList/{userId}")
    public R getBlogList(@PathVariable("userId")String userId) {
        R r = blogService.getBlogList(userId);
        return r;
    }

    @RequestMapping("/publicKey")
    public R publicKey() {
        R r = blogService.getBlogList("1");
        return r;
    }
    @RequestMapping("/getDetailBlog/{id}")
    public R getDetailBlog(@PathVariable("id") Integer id) {
        Blog byId = blogService.getById(id);
        R r = new R();
        r.put("data",byId);
        return r;
    }
}
